<%@ page import="cn.io0288.blog2.model.Article" %>
<%@ page import="static cn.io0288.blog2.utils.DateUtils.timeStamp2Date" %>
<%@ page import="static cn.io0288.blog2.utils.StringUtils.merge_str" %>
<%@ page import="cn.io0288.blog2.db.Classify" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    Article a = (Article) request.getAttribute("article");
%>

<header class="mt-3 mb-3 container">
    <section class="row">
        <div class="yy col-12 card bg-light text-white mu-3 mb-3" style="
                background-image: url('<%=a.img%>');
                min-height: 40vh;
                max-height: 50vh;">
            <div class="card-img-overlay">
            </div>
        </div>
    </section>
</header>

<main class="container" style="min-height: 50vh;">
    <br>
    <h1>
        <%=merge_str(a.title, a.title2)%>
    </h1>
    <hr>
    <small class="text-muted">创建于：<%=timeStamp2Date(Long.valueOf(a.date))%>
        /最后修改于：<%=timeStamp2Date(Long.valueOf(a.lastdate))%> |
    </small>
    <small class="text-muted"><a class="text-info" href="<c:url value="/search"/>?q=<%=a.cid%>"><%=a.cid%>
        :<%=Classify.getClassify(a.cid)%>
    </a></small>
    <c:if test="${not empty sessionScope.uemail}">
        <small class="text-muted"> | <a class="text-info" href="<c:url value="/update/"/><%=a.aid%>">Edit</a></small>
    </c:if>
    <br><br>
    <div id="ach">
        <%--        <%=a.content%>--%>
    </div>
    <script src="<c:url value="/js/marked.min.js"/>"></script>
    <script>
        window.onload = function () {
            // articleContent = `{{$article->content;}}`;//todo 使用`会导致报错
            articleContent = `<%=a.content.replace("`","\\`")%>`;
            ach = document.getElementById("ach")
            ach.innerHTML = marked.parse(articleContent);
        }
    </script>
</main>